Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy AngularJS Tutorials</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> </head> <body> <h3>ng-pattern Directive in AngularJS Tutorial </h3> <form ng-app="myApp" ng-controller="patternCtrl" name="myform"> Enter Mobile Number : <input type="text" name="number" ng-model="number" required ng-pattern="/^[0-9]+$/" > <span style="color:red" > <span ng-show="myform.number.$error.required">Number is required.</span> <span ng-show="myform.number.$error.pattern">Pattern does not match</span><br/><br/> </span> <input type="submit" value="submit"/> </form> <script> var app = angular.module("myApp", []); app.controller("patternCtrl", function($scope) { }); </script> </body> </html>
www.wikitechy.com © Copyright 2016. All Rights Reserved.